import request from '@/utils/request'

// 创建商户单
export function createAppMerchantOrder(data) {
  return request({
    url: '/pekingfish/app-merchant-order/create',
    method: 'post',
    data: data
  })
}

// 更新商户单
export function updateAppMerchantOrder(data) {
  return request({
    url: '/pekingfish/app-merchant-order/update',
    method: 'put',
    data: data
  })
}

// 扣积分
export function deductPoints(data) {
  return request({
    url: '/pekingfish/app-merchant-order/deductPoints',
    method: 'put',
    data: data
  })
}
export function deductMoney(data) {
  return request({
    url: '/pekingfish/app-merchant-order/deductMoney',
    method: 'put',
    data: data
  })
}

export function refundAndReturn(data) {
  return request({
    url: '/pekingfish/app-merchant-order/refundAndReturn',
    method: 'put',
    data: data
  })
}


// 删除商户单
export function deleteAppMerchantOrder(id) {
  return request({
    url: '/pekingfish/app-merchant-order/delete?id=' + id,
    method: 'delete'
  })
}

// 获得商户单
export function getAppMerchantOrder(id) {
  return request({
    url: '/pekingfish/app-merchant-order/get?id=' + id,
    method: 'get'
  })
}

// 获得商户单分页
export function getAppMerchantOrderPage(query) {
  return request({
    url: '/pekingfish/app-merchant-order/page',
    method: 'get',
    params: query
  })
}

export function confirmReceipt(id) {
  const data = {
    id
  }
  return request({
    url: '/pekingfish/app-merchant-order/confirmReceipt',
    method: 'put',
    data: data
  })
}

export function notDelivered(id) {
  const data = {
    id
  }
  return request({
    url: '/pekingfish/app-merchant-order/notDelivered',
    method: 'put',
    data: data
  })
}

// 导出商户单 Excel
export function exportAppMerchantOrderExcel(query) {
  return request({
    url: '/pekingfish/app-merchant-order/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}
